//
//  HLTabBarViewController.m
//  HLMusicBox
//
//  Created by hulinhu on 2017/12/26.
//  Copyright © 2017年 hulinhu. All rights reserved.
//

#import "HLTabBarViewController.h"
#import "HLBaseViewController.h"
#import "HLNavagationController.h"

#import "HLHomeController.h"
#import "HLDiscoverController.h"
#import "HLMessageController.h"
#import "HLMineController.h"

@interface HLTabBarViewController ()

@end

@implementation HLTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setSubViewController];
}
-(void)setSubViewController {
    
    // 首页
    HLHomeController * VC1 = [[HLHomeController alloc] init];
    [self addController:VC1 withTitle:@"首页" imageName:@"tabbar_home"];
    
    // 消息
    HLMessageController *VC2 = [[HLMessageController alloc] init];
    [self addController:VC2 withTitle:@"消息" imageName:@"tabbar_message_center"];

    // 发现
    HLDiscoverController *VC3 = [[HLDiscoverController alloc] init];
    [self addController:VC3 withTitle:@"发现" imageName:@"tabbar_discover"];

    // 我的
    HLMineController * VC4 = [[HLMineController alloc]init];
    [self addController:VC4 withTitle:@"我" imageName:@"tabbar_profile"];

}

#pragma mark - 添加子视图控制器
- (void)addController:(UIViewController *)controller withTitle:(NSString *)title imageName:(NSString *)imageName{
    
    HLNavagationController *navController = [[HLNavagationController alloc] initWithRootViewController:controller];
    // 导航标题
    controller.title = title;
    
    // 设置tabBarItem的子视图
    navController.tabBarItem.title = title;
    navController.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    NSString *selectImage =  [NSString stringWithFormat:@"%@_highlighted",imageName];
    navController.tabBarItem.selectedImage = [[UIImage imageNamed:selectImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    // 将视图控制器添加到标签栏控制器中
    [self addChildViewController:navController];
}





@end
